home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / IBM VisualAge for Java Enterprise v4.0 Retail / ivj40 / setup / IDE.Cab / F77613_CBSmartGuideNotebookUINavButton.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-04-25  |  4.3 KB  |  129 lines

  1. package com.ibm.ivb.sguides.cb;
  2.  
  3. import com.ibm.ivb.sguides.SmartGuideNotebook;
  4. import com.ibm.ivb.sguides.SmartGuidePage;
  5. import java.awt.Component;
  6. import java.awt.Insets;
  7. import java.awt.Point;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. import javax.swing.AbstractButton;
  11. import javax.swing.ButtonModel;
  12. import javax.swing.JButton;
  13. import javax.swing.JCheckBoxMenuItem;
  14. import javax.swing.JComponent;
  15. import javax.swing.JMenuItem;
  16. import javax.swing.JPopupMenu;
  17. import javax.swing.event.ChangeEvent;
  18. import javax.swing.event.ChangeListener;
  19. import javax.swing.event.PopupMenuEvent;
  20. import javax.swing.event.PopupMenuListener;
  21.  
  22. class CBSmartGuideNotebookUI$NavButton extends JButton implements ChangeListener, ActionListener, PopupMenuListener {
  23.    // $FF: synthetic field
  24.    private final CBSmartGuideNotebookUI this$0;
  25.    JPopupMenu popup;
  26.    // $FF: renamed from: ch com.ibm.ivb.sguides.cb.CBSmartGuideNotebookUI.CommandHandler
  27.    CBSmartGuideNotebookUI.CommandHandler field_0;
  28.    SmartGuideNotebook sgbook;
  29.    boolean myCancel;
  30.    // $FF: renamed from: pl java.awt.Point
  31.    Point field_1;
  32.    boolean pressed;
  33.  
  34.    public CBSmartGuideNotebookUI$NavButton(CBSmartGuideNotebookUI var1, SmartGuideNotebook var2) {
  35.       super(CBSmartGuideNotebookUI.navIcon);
  36.       this.this$0 = var1;
  37.       this.this$0 = var1;
  38.       this.myCancel = false;
  39.       this.pressed = false;
  40.       ((AbstractButton)this).addChangeListener(this);
  41.       ((AbstractButton)this).addActionListener(this);
  42.       this.sgbook = var2;
  43.       ((JComponent)this).setOpaque(false);
  44.    }
  45.  
  46.    public void setPopupLocation(Point var1) {
  47.       this.field_1 = var1;
  48.    }
  49.  
  50.    public void updateUI() {
  51.       super.updateUI();
  52.       ((AbstractButton)this).setMargin(new Insets(2, 2, 2, 2));
  53.       ((AbstractButton)this).setBorderPainted(false);
  54.       ((AbstractButton)this).setRolloverEnabled(true);
  55.       ((JComponent)this).setRequestFocusEnabled(false);
  56.       ((JComponent)this).setBorder(CBSmartGuideNotebookUI.navBorder);
  57.    }
  58.  
  59.    public boolean isFocusTraversable() {
  60.       return false;
  61.    }
  62.  
  63.    public void actionPerformed(ActionEvent var1) {
  64.       if (this.popup != null && this.myCancel) {
  65.          this.popup.setVisible(false);
  66.          this.myCancel = false;
  67.       } else {
  68.          this.makePopup();
  69.          if (this.popup != null) {
  70.             Point var2 = this.sgbook.getLocationOnScreen();
  71.             int var3 = var2.x + this.field_1.x;
  72.             int var4 = var2.y + this.field_1.y;
  73.             this.popup.setLocation(var3, var4);
  74.             this.popup.setVisible(true);
  75.             this.myCancel = false;
  76.          }
  77.  
  78.       }
  79.    }
  80.  
  81.    public void stateChanged(ChangeEvent var1) {
  82.       ButtonModel var2 = ((AbstractButton)this).getModel();
  83.       this.pressed = var2.isArmed() && var2.isPressed();
  84.       ((AbstractButton)this).setBorderPainted(var2.isRollover());
  85.       ((Component)this).repaint();
  86.    }
  87.  
  88.    public void popupMenuCanceled(PopupMenuEvent var1) {
  89.       this.myCancel = this.pressed;
  90.    }
  91.  
  92.    public void popupMenuWillBecomeInvisible(PopupMenuEvent var1) {
  93.    }
  94.  
  95.    public void popupMenuWillBecomeVisible(PopupMenuEvent var1) {
  96.    }
  97.  
  98.    void makePopup() {
  99.       if (this.popup == null) {
  100.          this.popup = new JPopupMenu();
  101.          this.popup.setInvoker(this.sgbook.getParent());
  102.          this.field_0 = new CBSmartGuideNotebookUI.CommandHandler(this.this$0, this.sgbook);
  103.          this.popup.addPopupMenuListener(this);
  104.       } else {
  105.          this.popup.removeAll();
  106.       }
  107.  
  108.       boolean var1 = true;
  109.       SmartGuidePage var2 = this.sgbook.getCurrentPage();
  110.  
  111.       for(SmartGuidePage var3 = this.sgbook.getPageAt(0); var3 != null; var3 = var3.getNextPage()) {
  112.          Object var4 = var3 == var2 ? new JCheckBoxMenuItem(var3.getTitle()) : new JMenuItem(var3.getTitle());
  113.          ((AbstractButton)var4).setActionCommand(var3.toString());
  114.          ((JComponent)var4).putClientProperty("SmartGuidePage", var3);
  115.          if (var3 == var2) {
  116.             var1 = false;
  117.             ((JMenuItem)var4).setEnabled(false);
  118.             ((JCheckBoxMenuItem)var4).setSelected(true);
  119.          } else if (!var1) {
  120.             ((JMenuItem)var4).setEnabled(var2.isPageComplete());
  121.          }
  122.  
  123.          ((AbstractButton)var4).addActionListener(this.field_0);
  124.          this.popup.add((JMenuItem)var4);
  125.       }
  126.  
  127.    }
  128. }
  129.